<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative; height:24px;"> 温馨提示：暂时不开放删除功能！
    <div class="content-menu" style="position: absolute; right: 30px;top: 5px;"> 
    <eq name="Think.session.user_id" value="1"><a href="javascript:openWinBox('__URL__/addGroup','添加分组');" class="add fb"><em>添加分组</em></a> </eq>
    </div>
  </div>
</div>
<!--subnav-->

<div class="pad-lr-10">
    <div class="table-list">
    <form name="listForm" id="listForm" action="__URL__/updateGroupSort" method="GET">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <th align="center" width="50">排序</th>
            <th align="center" width="20">ID</th>
            <th align="left" style="padding-left:50px;" width="120">分组名称</th>
            <th align="left">备注信息</th>
            <th align="center" width="50">状态</th>
            <th align="center" width="120">创建人</th>
            <th align="center" width="120">创建时间</th>
            <th align="center" width="120">管理操作</th>
          </tr>
        </thead>
        <tbody id="list">
          <volist name="list" id="vo">
            <tr id="list_{$vo.id}">
              <td align="center"><input name='sortArr[]' type='text' size="4" value='{$vo.sort}' class='input-text-c'><input name='idArr[]' type="hidden" value='{$vo.id}'></td>
              <td align="center" >{$vo.id}</td>
              <td align="left" style="padding-left:50px;">{$vo.name}</td>
              <td align="left">{$vo.remark}</td>
              <td align="center"><a href="javascript:changeStatus({$vo.id});" id="status-{$vo.id}" name="{$vo.status}" title="" class="status" >{$vo.statusName}</a></td>
              <td align="center" width="120">{$vo.creater}</td>
              <td align="center">{$vo.create_time|date='Y-m-d H:i:s',###}</td>
              <td align="center"><a href="javascript:openWinBox('__URL__/addGroup/id/{$vo.id}','编辑分组信息');" >编辑</a></td>
            </tr>
          </volist>
          <empty name="list">
            <tr>
              <td colspan="5" align="center">请添加电话分组</td>
            </tr>
          </empty>
        </tbody>
      </table>
      <div class="btn">
        <div id="pages">{$page}</div>
        <input name="submit" type="submit" class="button" value="更新排序" >
      </div>
      </form>
    </div>
</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
	$(".status").each(function(i, val) {
        var status = $(this).attr('name');
		if(status==1){
			$(this).addClass('blue');
		}else{
			$(this).addClass('red');
		}
    });


	$('#listForm').submit(function(){
       // 加入需要的操作代码
       $('#listForm').ajaxSubmit({
           beforeSubmit:  checkForm,
           success:       complete
       });
       return false;
	});

	function checkForm(){
		return true;
	}

	var origin = $.artDialog.open.origin;
    function complete(data){
		if(data.status==1){
			art.dialog({id:'TNCICC',content: data.info,time: 2,icon:'succeed'});
		}else{
			art.dialog({id:'TNCICC',content: data.info,time: 2,icon:'warning'});
		}
		setTimeout(function(){origin.location.reload();},1000);
    }
})

function checkall(){
	$("input[name=idArr[]]").each(function(){
		if(this.checked == false)
			this.checked = true;
		else
			this.checked = false;
	});
}

//异步修改状态
function changeStatus(id){
	var statusId = $("#status-"+id).attr('name');
	$.get("__URL__/changeGroupStatus/id/"+id+"/statusId/"+statusId, function(data) {
	if(statusId==1){
			$("#status-"+id).text('已禁用');
			$("#status-"+id).attr('name',0);
			$("#status-"+id).attr('class','red');
		}else{
			$("#status-"+id).text('已启用');
			$("#status-"+id).attr('name',1);
			$("#status-"+id).attr('class','blue');
		}
	});
}
</script>